public class test {
    //蓝桥杯 全球变暖(⭐⭐⭐)
    public class Main {
        public static int row;
        public static int col;
        public static char[][] nums;
        public static boolean[][] count;
        public static int[] dx = {0,0,1,-1};
        public static int[] dy = {1,-1,0,0};
        public static int num;//被淹没的岛屿数量
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            //在此输入您的代码...
            int n = in.nextInt();
            row = n;col = n;
            nums = new char[row][col];
            count = new boolean[row][col];
            for(int i = 0;i < row;i++){
                String s = in.next();
                for(int j = 0;j < col;j++){
                    nums[i][j] = s.charAt(j);
                }
            }
            for(int i = 0;i < row;i++){
                for(int j = 0;j < col;j++){
                    if(nums[i][j] == '#' && !count[i][j]){
                        count[i][j] = true;
                        bfs(i,j);
                    }
                }
            }
            System.out.println(num);
            in.close();
        }
        public static void bfs(int nx,int ny){
            int size = 1;//存储陆地块数,用于后续判断该岛屿是否全部被淹没
            Queue<int[]> queue = new LinkedList<>();
            queue.add(new int[]{nx,ny});
            //用于存储此次会被淹没的岛屿
            Queue<int[]> delete = new LinkedList<>();
            while(!queue.isEmpty()){
                int flg = 0;//标记当前陆地附近是否存在海域
                int[] t = queue.poll();
                for(int i = 0;i < 4;i++){
                    int x = t[0] + dx[i];
                    int y = t[1] + dy[i];
                    if(x >= 0 && x < row && y >= 0 && y < col && !count[x][y]){
                        // 1. 查找到陆地,放入
                        if(nums[x][y] == '#'){
                            queue.add(new int[]{x,y});
                            count[x][y] = true;
                            size++;
                        }// 2. 查找到海洋,该块陆地被淹没
                        else {
                            if(flg == 0) {
                                delete.add(new int[]{t[0], t[1]});
                                flg++;
                            }
                        }
                    }
                }
                //不能探索后直接修改
                //这样会导致探索到内部陆地时,外部陆地已经变成了海域
            }
            //删除沿海岛屿
            while(!delete.isEmpty()){
                int[] t = delete.poll();
                nums[t[0]][t[1]] = '.';
                size--;
            }
            if(size == 0){
                num++;
            }
        }
    }
    //蓝桥杯 最大连通(⭐⭐⭐)
    public class Main {
        public static int row;
        public static int col;
        public static int max;
        public static int[][] nums;
        public static boolean[][] count;
        public static int[] dx = {0,0,1,-1};
        public static int[] dy = {1,-1,0,0};
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            //row = 30;col = 60;
            //nums = new int[row][col];
            //count = new boolean[row][col];
            //for(int i = 0;i < row;i++){
            //    String s = in.next();
            //    for(int j = 0;j < col;j++){
            //        nums[i][j] = (int)s.charAt(j) - '0';
            //    }
            //}
            //for(int i = row - 1;i >= 0;i--){
            //    for(int j = col - 1;j >= 0;j--){
            //        if(nums[i][j] == 1 && !count[i][j]){
            //            count[i][j] = true;
            //            bfs(i,j);
            //        }
            //    }
            //}
            System.out.println(148);
        }
        public static void bfs(int nx,int ny){
            int n = 1;
            Queue<int[]> queue = new LinkedList<>();
            queue.add(new int[]{nx,ny});
            while(!queue.isEmpty()){
                int[] t = queue.poll();
                for(int i = 0;i < 4;i++){
                    int x = t[0] + dx[i];
                    int y = t[1] + dy[i];
                    if(x >= 0 && x < row && y >= 0 && y < col && !count[x][y] && nums[x][y] == 1){
                        n++;
                        count[x][y] = true;
                        queue.add(new int[]{x,y});
                    }
                }
            }
            max = Math.max(max,n);
        }
    }
}
